package cn.itsource.fallback;

import cn.itsource.api.openfeign.ILoginApiToService;
import cn.itsource.constants.Constants;
import cn.itsource.constants.ErrorCode;
import cn.itsource.pojo.dto.LoginRo;
import cn.itsource.result.JSONResult;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class LoginFallback implements FallbackFactory<ILoginApiToService> {
    @Override
    public ILoginApiToService create(Throwable cause) {
        return new ILoginApiToService() {
            @Override
            public JSONResult saveLogin(LoginRo loginRo) {
                return JSONResult.error(cause.getMessage()+ ErrorCode.SERVICE_OPENFEIGN_ERROR);
            }
        };
    }
}
